import { ref } from "vue";

/**
 * 新增/详情 add-and-detail组件弹窗的控制函数
 * @returns {Object} 包含 open、currRow、currIdx、title、mode、resetForm 等属性的对象
 */
export default function useControl() {
  const open = ref<boolean>(false);
  const currRow = ref<any>();
  const currIdx = ref<any>();
  const title = ref<string>("新增");
  const mode = ref<"write" | "read">("write");
  const resetForm = () => {
    currRow.value = null;
    currIdx.value = null;
    title.value = "新增";
  };
  return {
    open,
    currRow,
    currIdx,
    title,
    mode,
    resetForm,
  };
}
